import permissionApi from '@/api/permissionApi';

const permission = {
  state: {
    permissionList: []
  },
  mutations: {
    setPermissionList: (state, permissionList) => { state.permissionList = permissionList; }
  },
  actions: {
    GetPermissions ({ commit, state }) {
      return new Promise(resolve => {
        permissionApi.getList().then(res => {
          if (res) {
            commit('setPermissionList', res);
            resolve(true);
          } else {
            resolve(false);
          }
        }).catch(() => resolve(false));
      });
    }
  }
}

export default permission;
